<?php

// This example request includes an optional API key which you will need to
// remove or replace with your own key.
// Read more about why it's useful to have an API key.
// The request also includes the userip parameter which provides the end
// user's IP address. Doing so will help distinguish this legitimate
// server-side traffic from traffic which doesn't come from an end-user.

function googleSearch($query, $type, $rowsPerPage) {
$url = "https://ajax.googleapis.com/ajax/services/search/".$type."?v=1.0&"
    . "q=".$query."&rsz=".$rowsPerPage."&key=ABQIAAAAV8m5NfCG02kKCu_qiOasWhSnaGTv943xE_57a5sjcHb4suKNXRRN6A-flXCv28OZRFOcgfNjdddWJw&userip=184.73.221.169";

// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://dev.bitzermobile.com");
$body = curl_exec($ch);
curl_close($ch);

// now, process the JSON string
$json = json_decode($body);

$response = $json->{'responseData'};

print_r($response);

return $json->responseData->results;
}
?>
